package com.archerdu.apply.model;

// default package
// Generated 2013-11-5 9:11:21 by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.List;

import org.dom4j.Element;

import com.archerdu.base.dao.TreeNode;

/**
 * Entity:
 */
public class ProductCatalog implements TreeNode<ProductCatalog, String> {

    private static final long      serialVersionUID = 1L;

    /**
     * 目录编号，5位数字，高位补0，从00001开始，每次递增1，由序列和触发器控制.
     */
    private String                 id;

    /**
     * 目录类型，备用，可以设置共享目录等.
     */
    private Character              type;

    /**
     * 目录名称.
     */
    private String                 name;

    /**
     * 目录描述.
     */
    private String                 note;

    /**
     * 目录完整编码，例如0000100002，不包含自身.
     */
    private String                 code;

    /**
     * 上级目录.
     */
    private String                 parentId;

    /**
     * 目录等级，默认0级.
     */
    private Integer                lev;

    /**
     * 目录创建人，默认0为系统创建.
     */
    private Integer                createUser;

    /**
     * 目录最后修改人，默认0为系统创建.
     */
    private Integer                updateUser;

    /**
     * 目录创建时间.
     */
    private Date                   createtime;

    /**
     * 目录最后修改时间.
     */
    private Date                   updatetime;

    /**
     * 只为实现触发器使用的字段，实体中不需要映射此字段.
     */
    private int                    incrId;
    /**
     * 子目录
     */
    private List<ProductCatalog> children;

    public ProductCatalog() {
    }

    public ProductCatalog(String name, String code, int incrId) {
        this.name = name;
        this.code = code;
        this.incrId = incrId;
    }

    public ProductCatalog(Character type, String name, String note, String code, String parentId, Integer lev,
            Integer createUser, Integer updateUser, Date createtime, Date updatetime, int incrId) {
        this.type = type;
        this.name = name;
        this.note = note;
        this.code = code;
        this.parentId = parentId;
        this.lev = lev;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.createtime = createtime;
        this.updatetime = updatetime;
        this.incrId = incrId;
    }

    /**
     * toJson
     * 
     * @return String
     */
    public String toJson() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("{");
        buffer.append("\"type\":\"" + type + "\",");
        buffer.append("\"name\":\"" + name + "\",");
        buffer.append("\"note\":\"" + note + "\",");
        buffer.append("\"code\":\"" + code + "\",");
        buffer.append("\"parentId\":\"" + parentId + "\",");
        buffer.append("\"lev\":\"" + lev + "\",");
        buffer.append("\"createUser\":\"" + createUser + "\",");
        buffer.append("\"updateUser\":\"" + updateUser + "\",");
        buffer.append("\"createtime\":\"" + createtime + "\",");
        buffer.append("\"updatetime\":\"" + updatetime + "\",");
        buffer.append("\"incrId\":\"" + incrId + "\",");
        buffer.deleteCharAt(buffer.length() - 1);
        buffer.append("}");
        return buffer.toString();
    }

    @Override
    public String toString() {

        StringBuffer buffer = new StringBuffer();

        buffer.append("[");

        buffer.append("\"目录类型，备用，可以设置共享目录等\":\"" + type + "\",");

        buffer.append("\"目录名称\":\"" + name + "\",");

        buffer.append("\"目录描述\":\"" + note + "\",");

        buffer.append("\"目录完整编码，例如0000100002，不包含自身\":\"" + code + "\",");

        buffer.append("\"上级目录\":\"" + parentId + "\",");

        buffer.append("\"目录等级，默认0级\":\"" + lev + "\",");

        buffer.append("\"目录创建人，默认0为系统创建\":\"" + createUser + "\",");

        buffer.append("\"目录最后修改人，默认0为系统创建\":\"" + updateUser + "\",");

        buffer.append("\"目录创建时间\":\"" + createtime + "\",");

        buffer.append("\"目录最后修改时间\":\"" + updatetime + "\",");

        buffer.append("\"只为实现触发器使用的字段，实体中不需要映射此字段\":\"" + incrId + "\",");

        buffer.deleteCharAt(buffer.length() - 1);
        buffer.append("]");
        return buffer.toString();
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Character getType() {
        return this.type;
    }

    public void setType(Character type) {
        this.type = type;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNote() {
        return this.note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getParentId() {
        return this.parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getLev() {
        return this.lev;
    }

    public void setLev(Integer lev) {
        this.lev = lev;
    }

    public Integer getCreateUser() {
        return this.createUser;
    }

    public void setCreateUser(Integer createUser) {
        this.createUser = createUser;
    }

    public Integer getUpdateUser() {
        return this.updateUser;
    }

    public void setUpdateUser(Integer updateUser) {
        this.updateUser = updateUser;
    }

    public Date getCreatetime() {
        return this.createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public Date getUpdatetime() {
        return this.updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    public int getIncrId() {
        return this.incrId;
    }

    public void setIncrId(int incrId) {
        this.incrId = incrId;
    }

    @Override
    public List<ProductCatalog> getChildren() {
        return children;
    }

    @Override
    public void setChildren(List<ProductCatalog> children) {
        this.children = children;
    }

    @Override
    public void toElement(Element ele) {
        // TODO Auto-generated method stub
    }

}
